package app.cn.com.school.fragment

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import app.cn.com.school.R
import app.cn.com.school.activity.*
import app.cn.com.school.databinding.FragmentMineBinding

/**
 * Created by Administrator on 2017/11/1 0001.
 */
class MineFragment : BaseFragment<FragmentMineBinding>() {
    override fun initBindingVar() {
    }

    private var mParam1: String? = null
    private var mParam2: String? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (arguments != null) {
            mParam1 = arguments.getString(ARG_PARAM1)
            mParam2 = arguments.getString(ARG_PARAM2)
        }
    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        initBinding(R.layout.fragment_mine, container)
        mView = binding.root
        initView()
        return super.onCreateView(inflater, container, savedInstanceState)
    }


    private fun initView() {
        //设置
        binding.mineSetting.setOnClickListener {
            startActivity(Intent(context, SettingActivity::class.java))
        }
        //消息
        binding.mineNews.setOnClickListener {
            startActivity(Intent(context, NewsActivity::class.java))
        }

        //个人信息
        binding.mineInfo.setOnClickListener { startActivity(Intent(context, UserInfoActivity::class.java)) }

        //金豆
        binding.mineLinFortunella.setOnClickListener {
            startActivity(Intent(context, VenosaActivity::class.java))
        }

        //我的积分
        binding.mineLinIntegral.setOnClickListener {
            startActivity(Intent(context, IntegralActivity::class.java).putExtra("type", "1"))
        }

        //退货 退款、
        binding.mineLinQuit.setOnClickListener {
            startActivity(Intent(context, IntegralActivity::class.java).putExtra("type", "0"))
        }

        //购物车
        binding.mineLinShopping.setOnClickListener {
            startActivity(Intent(context, ShoppingCarActivity::class.java))
        }

        //折扣卷
        binding.mineLinCoupon.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("type", "2"))
        }

        //收藏
        binding.mineLinCollect.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("type", "0"))
        }

        //二手
        binding.mineLinUsed.setOnClickListener {
            startActivity(Intent(context, IntegralActivity::class.java).putExtra("type", "2"))
        }

        //评选
        binding.mineLinAppraise.setOnClickListener {
            startActivity(Intent(context, IntegralActivity::class.java).putExtra("type", "3"))
        }

        //申请店铺
        binding.mineLinApplyShop.setOnClickListener {
            startActivity(Intent(context,ApplyShopActivity::class.java))
        }

        //全部
        binding.mineLinItem1.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("set", "0").putExtra("type", "1"))
        }
        //待付款
        binding.mineLinItem2.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("set", "1").putExtra("type", "1"))
        }
        //待发货
        binding.mineLinItem3.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("set", "2").putExtra("type", "1"))
        }
        //待收货
        binding.mineLinItem4.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("set", "3").putExtra("type", "1"))
        }
        //待评价
        binding.mineLinItem5.setOnClickListener {
            startActivity(Intent(context, OrdersListActivity::class.java).putExtra("set", "4").putExtra("type", "1"))
        }

    }


    companion object {
        private val ARG_PARAM1 = "param1"
        private val ARG_PARAM2 = "param2"
        fun newInstance(param1: String, param2: String): MineFragment {
            val fragment = MineFragment()
            val args = Bundle()
            args.putString(ARG_PARAM1, param1)
            args.putString(ARG_PARAM2, param2)
            fragment.arguments = args
            return fragment
        }
    }

}